<?
include 'koneksi.php';
$nrp=$_GET['nrp'];
$queri=mysql_query("select * from registrasi where nrp='$nrp' order by hari desc");
//$row=mysql_fetch_row($queri);
$queri3=mysql_query("select nama from biodata where nrp='$nrp'");
$row3=mysql_fetch_row($queri3);
$array=mysql_fetch_array($queri);


define('FPDF_FONTPATH','font/');
require('fpdf.php');

class PDF extends FPDF {
var $col=0;
var $y0;

	function Header() {
		$this->Image('images/logo_uwika.jpg',1.5,1.3,1.7);
		$this->SetFont('Arial','B',24);
		$this->SetTextColor(0,0,0);
		$this->Cell(19,1,'Universitas Widya Kartika','T',0,'C');
		$this->Ln();
		$this->Cell(19,1,'Pengajuan KRS','B',0,'C');
		$this->Ln(2);
	}

	function Footer() {
		$this->SetY(-7.5);
		$this->Cell(0,1,'Mengetahui,',0,0,'R');
		$this->SetY(-7);
		$this->Cell(0,1,'K.A Prodi',0,0,'R');
		$this->SetY(-4);
		/*
		$jur=substr($nrp,0,3);	
		//$this->Cell(0,1,$jur,0,0,'R');

		switch($jur)
		{
			case 311:echo "Infor";break;
			case 111:echo "Akun";break;
			case 112:echo "Man";break;
			case 611:echo "BT";break;
		}
		*/
		$this->Cell(0,1,'(...........................)',0,0,'R');
		$this->SetY(-1.5);
		$this->SetFont('Arial','I',8);
		//$this->Cell(0,1,'Halaman '.$this->PageNo().'/{nb}',0,0,'L');
		$tanggal=date("d M Y",time());
		$this->SetFont('Arial','',10);
		$this->Cell(0,1,'Dicetak tanggal: '.$tanggal,0,0,'R');
	} 
}

$pdf=new PDF('P','cm','A4');
$pdf->Open();
//$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Arial','B',12);
$pdf->Cell(3,0.7,'NIM',0,0,'L');
$pdf->Cell(14,0.7,': '.$nrp,0,0,'L');
$pdf->Ln();
$pdf->Cell(3,0.7,'Nama',0,0,'L');
$pdf->Cell(14,0.7,': '.$row3[0],0,0,'L');
$pdf->Ln(1);
$pdf->SetFont('Arial','B',10);
$pdf->Cell(1,1,'No','TB',0,'C');
$pdf->Cell(2,1,' Kode','TB',0,'L');
$pdf->Cell(10,1,' Mata Kuliah','TB',0,'L');
$pdf->Cell(1.5,1,'B/U','TB',0,'C');
//$pdf->Cell(1.5,1,'Bobot','TB',0,'C');
$pdf->Cell(1.5,1,'SKS','TB',0,'C');
//$pdf->Cell(1.5,1,'Nilai','TB',0,'C');
$pdf->Ln();
$pdf->SetFont('Arial','',10);

$i = 1;
while($row=mysql_fetch_row($queri))
{	
	$queri2=mysql_query("select nama from mk111 where kodemk='$row[1]'");
	$row2=mysql_fetch_row($queri2);
	$pdf->Cell(1,0.7,$i,0,0,'R');
	$pdf->Cell(2,0.7,'  '.$row[1],0,0,'L');
	$pdf->Cell(10,0.7,'  '.$row2[0],0,0,'L');
	if($row[3] == 'BARU')
	{
		$pdf->Cell(1.5,0.7,'B',0,0,'C');
	}
	else if($row[3] == 'ULANG')
	{
		$pdf->Cell(1.5,0.7,'U',0,0,'C');
	}
	else
	{
		$pdf->Cell(1.5,0.7,' ',0,0,'C');
	}
	//$pdf->Cell(1.5,0.7,number_format('$cell[$j][5]',1,',','.'),0,0,'R');
	$pdf->Cell(1.5,0.7,$row[12],0,0,'C');
	//$pdf->Cell(1.5,0.7,number_format('$cell[$j][7]',2,',','.'),0,0,'R');
	$totsks=$totsks+$row[12];
	$pdf->Ln();
	$i++;

}
$pdf->Cell(16,0,'',1,0);//16--> ngatur baris di atas total
$pdf->Ln();
$pdf->Cell(13,0.7,'',0,0,'R');
$pdf->Cell(1.5,0.7,'Total',0,0,'C');
$pdf->Cell(1.5,0.7,$totsks,0,0,'C');
//$pdf->Cell(1.5,0.7,number_format('$totalnilai',2,',','.'),0,0,'R');
$pdf->Ln();
$pdf->Cell(16,0,'',1,0);//16 --> ngatur garis paling bawah
$pdf->Ln();
/*
$ipk=number_format('$totalnilai/$totalsks',2,',','.');
$pdf->Cell(1,0.7,'IPK',0,0,'L');
$pdf->Cell(1,0.7,': '.'$ipk',0,0,'L');
$pdf->Ln(2);
*/
$pdf->Output();
?> 